package com.ashin.service.impl;

import cn.hutool.core.util.RandomUtil;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
@EnableScheduling
public class SchedulingTask {
    @Scheduled(fixedRate = 60*60*1000)
    public void sayHello() {
        System.out.println("hello");
        File directory = new File("data/voice");
        if (directory.exists() && directory.isDirectory()) {
            File[] files = directory.listFiles();
            if (files != null) {
                for (int i = 0; i < files.length; i++) {
                    if (files[i].isFile() && files[i].getName().contains("mirai_audio_")) {
                        boolean deleted = files[i].delete();
                    }
                }
            }
        }

    }
}
